<template>
  <!-- 消息更多 -->
  <div class="page_padding" :style="evaluationList.length == 0 ? 'backgroundColor:#f7f7f7' : ''">
    <MyNavBar @goback="goback" :title="title" />
    <div class="evaluation_con" :style="evaluationList.length == 0 ? 'backgroundColor:#f7f7f7' : ''">
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoadList"
        v-if="evaluationList.length > 0">
        <div class="evaluation_li" v-for="item in evaluationList" :key="item.id">
          <!-- <div class="leftQr" @click="goSignCode(item)" v-if="item.assessmentStatus == 2">
            <van-icon name="qr" />
            <p>签到码</p>
          </div> -->
          <div class="triangle-tips top-left" v-if="item.dataValid == '0'">
            <span>
              <em>无效</em>
            </span>
          </div>
          <div class="right" @click="goDetail(item)">
            <div class="evaluation_tit">
              {{ item.assessmentTitle }}
            </div>
            <div class="evaluation_li_label">
              <span :class="'label_type' + item.assessmentStatus">{{ statusTxt[item.assessmentStatus] }}</span>
              <span class="label_time">
                查看数据
                <van-icon name="arrow" />
              </span>
            </div>
          </div>
        </div>
      </van-list>
      <van-empty description="暂无数据" v-else />
    </div>
  </div>
</template>

<script>
import MyNavBar from '@com/MyNavBar'
import { listAssessmentData } from '@api/api-democratic.js'
export default {
  name: 'evaluationList',
  components: { MyNavBar },
  props: {},
  data() {
    return {
      title: '民主测评',
      evaluationList: [],
      currentPage: 1,
      pageSize: 10,
      evaluationTotalPages: 0,
      loading: false,
      finished: false,
      type: '0',
      activeTab: '1',
      statusTxt: {
        '-2': '草稿',
        '-1': '待审核',
        0: '审核未通过',
        1: '未开始',
        2: '进行中',
        3: '已结束',
      },
    }
  },
  mounted() {
    this.onLoadList()
  },
  methods: {
    goback() {
      this.$router.go(-1)
    },
    onChange(index) {},
    onLoadList() {
      listAssessmentData({
        pageNum: this.currentPage,
        pageSize: this.pageSize,
        key: this.key,
      })
        .then(res => {
          const data = res.data
          this.evaluationList.push(...data.content)
          this.evaluationTotalPages = data.totalSize
          this.currentPage++
          this.loading = false
          if (this.evaluationList.length === this.evaluationTotalPages) {
            this.finished = true
          }
        })
        .catch(err => {
          this.finished = true
        })
    },
    goDetail(item) {
      this.$router.push(`/evaluationDetail?id=${item.id}`)
    },
    goSignCode(item) {
      this.$router.push(`/signCode?id=${item.id}`)
    },
  },
}
</script>

<style lang="scss" scoped>
.evaluation_con {
  padding: 8px 16px;
  position: relative;
  background-color: #fff;
  .evaluation_li {
    // display: flex;
    padding: 16px 0;
    position: relative;
    .triangle-tips {
      position: absolute;
      z-index: 1;
      right: 0;
      height: 36px;
      width: 36px;
      display: flex;
      align-items: center;
      span {
        position: absolute;
        right: 0;
        width: 0;
        height: 0;
        em {
          position: absolute;
          height: 40px;
          width: 40px;
          line-height: 40px;
          text-align: center;
          color: #fff;
          font-style: normal;
          font-size: 12px;
        }
      }
      &.top-left {
        left: -15px;
        top: 0;
        span {
          top: 0;
          border-right: 36px solid transparent;
          border-top: 36px solid#d81e06;
        }
        em {
          top: -44px;
          left: -7px;
          transform: rotate(-45deg);
          -webkit-transform: rotate(-45deg);
        }
      }
    }
    &:not(:last-of-type) {
      border-bottom: 1px solid #efefef;
    }
    .leftQr {
      font-size: 12px;
      background: #eef4fa;
      text-align: center;
      color: #666;
      border-radius: 5px;
      padding: 5px;
      margin-right: 8px;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      i {
        font-size: 23px;
      }
    }
    .right {
      flex: 1;
      // padding: 16px 0;
    }
    .evaluation_tit {
      color: #333333;
      margin-bottom: 8px;
    }
    .evaluation_li_label {
      font-size: 13px;
      display: flex;
      justify-content: space-between;
      color: #666;
      .label_type-2 {
        color: #666;
      }
      .label_type-1 {
        color: #a57d60;
      }
      .label_type0 {
        color: #d81e06;
      }
      .label_type1 {
        color: #2c864e;
      }
      .label_type2 {
        color: #1852a3;
      }
      .label_type1 {
        color: #333;
      }
      .label_type3,
      .label_type4 {
        color: #666;
      }
      .label_time {
        font-size: 12px;
        color: #a57d60;
      }
    }
  }
}
</style>
